#define _CRT_SECURE_NO_WARNINGS 1
int majorityElement(int* nums, int numsSize) {
    int max = nums[0];
    int min = nums[0];
    for (int i = 0; i < numsSize; i++)
    {
        if (nums[i] < min)
        {
            min = nums[i];
        }
        if (nums[i] > max)
        {
            max = nums[i];
        }
    }
    int range = max - min + 1;
    int* count = (int*)calloc(range, sizeof(int));
    for (int i = 0;i < numsSize;i++)
    {
        count[nums[i] - min]++;
    }
    for (int i = 0;i < range;i++)
    {
        if (count[i] > numsSize / 2)
        {
            return i + min;
        }
    }
    free(count);
    return 0;
}